package com.splant.android.smart.SystemDefinedLevel.Notifications;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;

import com.splant.android.R;


/**
 * Created by Administrator on 2016/8/15.
 */
public class UpdateVersionNotification {


    private ProgressBar pro_downLoadFile;
    private final PopupWindow popupWindow;
    private View contentView;

    private Button btn_closeProgressNotify;

    public UpdateVersionNotification(Context context) {

        contentView = LayoutInflater.from(context).inflate(R.layout.system_download_popwindow, null);

        popupWindow = new PopupWindow(contentView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT, true);

        pro_downLoadFile= (ProgressBar) contentView.findViewById(R.id.pro_downLoadFile);
        btn_closeProgressNotify= (Button) contentView.findViewById(R.id.btn_closeProgressNotify);

        btn_closeProgressNotify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (popupWindow!=null)
                    popupWindow.dismiss();
            }
        });
    }

    public void showNotifyProgress(int progress) {

        if (progress==0)
        {
            if (popupWindow!=null)
            popupWindow.showAsDropDown(contentView);
        }

        if (pro_downLoadFile!=null)
            pro_downLoadFile.setProgress(progress);

    }
    public void cancelNotifyProgress()
    {
        if (popupWindow!=null)
        popupWindow.dismiss();
    }

}
